import React, { useState } from "react";
import { UserOutlined } from "@ant-design/icons";
import { IconFont } from "tdesign-icons-react";
import { useNavigate } from "react-router-dom";
import axios from "axios";
import './ybk.css';
function App() {
  const Navigate = useNavigate();
  const ored = () => {
    Navigate("/other");
  };
  const face = () => {
    Navigate("/face");
  };
  const [state, setState] = useState(false);
  const [password, setPassword] = useState("");
  const [username, setUsername] = useState("");
  const deng = () => {
    console.log(username, password);
    if (state) {
      axios
        .get("http://localhost:3000/ljydeng", {
          params: { username, password },
        })
        .then((res) => {
          if (res.data.code == 200) {
            alert("注册成功");
            setPassword("");
            setUsername("");
            Navigate("/other");
          } else {
            alert("注册失败");
          }
        });
    } else {
      alert("请先勾选");
    }
  };
  return (
    <div>
      <div
        style={{
          textAlign: "center",
          marginTop: "10rem",
          marginBottom: "10rem",
        }}
      >
        <div
          style={{
            width: "20rem",
            height: "20rem",
            lineHeight: "30rem",
            backgroundColor: "var(--item-bgc)",
            borderRadius: "50%",
            textAlign: "center",
            margin: "0 auto",
          }}
        >
          {/* <img src="../public/img/sdd1.png" alt="" className="ljyimg" /> */}
        </div>
      </div>
      <div className="ljylogin">
        <div className="ljydeng1">
          账号：
          <input
            type="text"
            onChange={(event) => setUsername(event.target.value)}
            value={username}
            placeholder="请输入账号与手机号一致"
          />
        </div>
        <div className="ljydeng1">
          密码：
          <input
            type="text"
            onChange={(event) => setPassword(event.target.value)}
            value={password}
            placeholder="请输入密码"
          />
        </div>
        <div>
          <button className="ljyphone" onClick={deng}>
            注册账号
          </button>
        </div>
        <div>
          <input
            type="radio"
            onClick={() => setState(!state)}
            checked={state}
          />
          我已读并同意<span className="ljytext">《法律条款以及隐私政策》</span>
        </div>
      </div>
    </div>
  );
}
export default App;
